﻿using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;

namespace AnesSystem.Models
{
    public class UdpMsgAnalysis
    {
        #region Variables

        //唯一标识
        private string sessionID = "";

        //系统类型 麻醉or重症
        private string systemType = "";

        //方法ID
        private string methodId = "";

        //自定义内容 对应 方法id
        private string customContent = "";

        //超时字段
        private string timeOut = "20";

        private string sendIp = "";
        #endregion

        #region Constructor
        public UdpMsgAnalysis()
        {
            
        }

        #endregion

        #region 属性

        /// <summary>
        /// 会话唯一标识
        /// </summary>
        public string SessionID
        {
            get
            {
                return sessionID;
            }

            set
            {
                sessionID = value;
            }
        }

        /// <summary>
        /// 系统类型 麻醉 or 重症
        /// </summary>
        public string SystemType
        {
            get
            {
                return systemType;
            }

            set
            {
                systemType = value;
            }
        }

        /// <summary>
        /// 方法id
        /// </summary>
        public string MethodId
        {
            get
            {
                return methodId;
            }

            set
            {
                methodId = value;
            }
        }

        /// <summary>
        /// 自定义内容 对应methodid
        /// </summary>
        public string CustomContent
        {
            get
            {
                return customContent;
            }

            set
            {
                customContent = value;
            }
        }

        public string TimeOut
        {
            get
            {
                return timeOut;
            }

            set
            {
                timeOut = value;
            }
        }

        public string SendIp
        {
            get
            {
                return sendIp;
            }

            set
            {
                sendIp = value;
            }
        }

        #endregion

        #region Event

        #endregion

        #region Private Methods
        //判断是否是IPV4
        private static bool IsValidIP(string ip)
        {
            if (System.Text.RegularExpressions.Regex.IsMatch(ip, "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"))
            {
                string[] ips = ip.Split('.');
                if (ips.Length == 4 || ips.Length == 6)
                {
                    if (System.Int32.Parse(ips[0]) < 256 && System.Int32.Parse(ips[1]) < 256 & System.Int32.Parse(ips[2]) < 256 & System.Int32.Parse(ips[3]) < 256)
                        return true;
                    else
                        return false;
                }
                else
                {
                    return false;
                }
            }
            else
                return false;
        }
        private static string UpdateIPs()
        {
            IPAddress[] ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            foreach (IPAddress item in ip)
            {
                if (IsValidIP(item.ToString()))
                {
                    return item.ToString();
                }
            }
            return "";
            //DataManager.Instance.CurRoom.Ips = ips;
        }
        #endregion

        #region Public/Protected Methods
       
        #endregion

        #region EventHandlers

        #endregion
    }

    public class AnesSystemModifyInfoModel
    {
        #region Variables

        //手术间
        private string roomID;
        //登陆人ID
        private string accountID;
        //操作的表单
        private string tableName;
        //病人id
        private string patientLinkId;
        //病人
        private string patientLink;
        //当前IP
        private string ip;
        //显示的消息内容
        private string displayMsg = "";

        #endregion

        #region Constructor

        public AnesSystemModifyInfoModel()
        {

        }

        #endregion

        #region Properties
        public string RoomID
        {
            get
            {
                return roomID;
            }

            set
            {
                roomID = value;
            }
        }

        public string AccountID
        {
            get
            {
                return accountID;
            }

            set
            {
                accountID = value;
            }
        }

        public string TableName
        {
            get
            {
                return tableName;
            }

            set
            {
                tableName = value;
            }
        }

        public string PatientLink
        {
            get
            {
                return patientLink;
            }

            set
            {
                patientLink = value;
            }
        }

        public string Ip
        {
            get
            {
                return ip;
            }

            set
            {
                ip = value;
            }
        }

        public string DisplayMsg
        {
            get
            {
                return displayMsg;
            }

            set
            {
                displayMsg = value;
            }
        }

        public string PatientLinkId
        {
            get
            {
                return patientLinkId;
            }

            set
            {
                patientLinkId = value;
            }
        }

        #endregion

        #region 依赖属性

        #endregion

        #region Event

        #endregion

        #region Private Methods

        #endregion

        #region Public/Protected Methods

        #endregion

        #region EventHandlers

        #endregion
    }
}
